<%@ page contentType="text/html; charset=utf-8" language="java" import="java.sql.*" errorPage="" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta http-equiv="Content-Script-Type" content="text/javascript" />
<meta http-equiv="Content-Script-Type" content="text/css" />
<title>修改配方</title>
<link type="text/css" href="/css/tablecloth.css" rel="stylesheet" media="screen" />
<script type="text/javascript" src="/js/jquery-1.4.4.js"></script>
<script type="text/javascript" src="/js/tablecloth.js" ></script>
<script type="text/javascript" src="/js/tableinput.js" ></script>
<script type="text/javascript">

function add()
{
	var form = document.getElementById("formulationForm");
	form.name.value = document.getElementById("idtd001").innerText;
	form.submit();
	alert("添加成功");
}

function deleteobj()
{
	var form = document.getElementById("formulationDelete");
	form.id.value = arguments[0];
	form.submit();
	alert("删除成功");
}

function printPDF(id)
{
	var form = document.getElementById("printPDF");
	form.id.value = id;
	form.submit();
}
</script>
</head>

<body>
	<form action = "/formulation/newFormulation.do" method="post" id="formulationForm">
		<input type="hidden" name="name" />
	</form>	
	
	<form action = "/formulation/deleteManageFormulation.do" method = "post" id="formulationDelete">
		<input type = "hidden" name = "id" />
	</form>
	
	<form action = "/formulation/viewPDF.do" method = "post" id ="printPDF">
		<input type = "hidden" name = "id" />
	</form>
		
	<table id = "t" cellspacing="0" cellpadding="0">
	<%@ page import="db.formulation.Formulation" %>
	<%@ page import="java.util.List" %>
	<%
		@SuppressWarnings("unchecked")
		List<Formulation> s = (List<Formulation>)request.getAttribute("formulations");
		String name = (String)session.getAttribute("name");
			
		if(name != null)
		{
			out.print("<tr><th class='title1'>配方</th>");
			out.print("<th class='title2'>导出PDF</th>");
			out.print("<th id='title3'>删除</th>");
			for(int i=0; i<s.size();i++)
			{
				out.print("<tr>");
				out.print("<td>"+s.get(i).getName()+"</td>");
				out.print("<td><input type='button' value='导出' onclick = printPDF(" + s.get(i).getId() + ") /></td>");
				out.print("<td><input type='button' value='删除' onclick = deleteobj(" + s.get(i).getId() + ") /></td>");
				out.print("</tr>");
			}
		}
        else
        {
			out.print("<tr><th class='title1'>配方</th>");
			out.print("<th class='title2'>导出PDF</th></tr>");
			for(int i=0; i<s.size();i++)
			{
				out.print("<tr>");
				out.print("<td>"+s.get(i).getName()+"</td>");
				out.print("<td><input type='button' value='导出' onclick = printPDF(" + s.get(i).getId() + ") /></td></tr>");
				out.print("</tr>");
			}
		}
	%>
	</table>
	<p>&nbsp;</p>
</body>
</html>
